package com.qf.boot2202day03.controller;

import com.qf.boot2202day03.annotation.NullValidation;
import com.qf.boot2202day03.vo.HelloVo;
import com.qf.boot2202day03.vo.ResultVo;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/hello")
public class HelloController {

    @GetMapping("aaa")
    public void test(){
        System.out.println("yes");
    }

    @GetMapping("/test1")
    public ResultVo test1(@Valid HelloVo helloVo){//使用@Valid,开启参数校验过程
        System.out.println(helloVo);
        return (new ResultVo(1,"ok"));
    }

    @PostMapping("/test2")
    public ResultVo test2(@Valid @RequestBody HelloVo helloVo){//使用@Valid,开启参数校验过程
        System.out.println(helloVo);
        return (new ResultVo(1,"ok"));
    }

    @NullValidation
    @RequestMapping("/test3")
    public ResultVo test3(@Valid HelloVo helloVo){//使用@Valid,开启参数校验过程
        System.out.println(helloVo);
        return (new ResultVo(1,"ok"));
    }
}
